package com.itbour.service.video.impl;

import java.util.List;
import java.util.Map;

import com.itbour.com.page.JspPage;
import com.itbour.com.page.Page;
import com.itbour.dao.video.VideoDesignInfoDao;
import com.itbour.dto.tg.KeywordInfoDto;
import com.itbour.dto.video.VideoDesignDto;
import com.itbour.dto.video.VideoUserDocDto;
import com.itbour.dto.video.YjxPriceInfoDto;
import com.itbour.service.video.VideoDesignInfoService;


/**
 * @author LQ
 * video设计 接口实现类
 */
public class VideoDesignInfoServiceImpl implements VideoDesignInfoService {
	
	private VideoDesignInfoDao videoDesignInfoDao;// 定视频DAO接口

	public Page pageVideoDesignInfo(Map<String, Object> parm, Integer pageNo,
			Integer pageSize) {
		try {
			Page result = null;
			int skipResults = JspPage.getStartOfPage(pageNo, pageSize);
			int totalSize = videoDesignInfoDao.getVideoDesignInfoCnt(parm);
			while(totalSize >0 && totalSize <= skipResults){
				skipResults= skipResults - pageSize;
				pageNo = pageNo -1;
			}
			parm.put("pageSize", pageSize);
			parm.put("skipResults", skipResults);
			List<VideoDesignDto> data = videoDesignInfoDao.getVideoDesignInfo(parm);
			result = new JspPage(skipResults, totalSize, pageSize, data);
			return result;
		} finally {
		}
	}

	//修改 视频设计模板
	public boolean updVideoDesignInfo(Map<String, Object> parm) {
		try {
			videoDesignInfoDao.updVideoDesignInfo(parm);
			return true;
		} catch (Exception e) {
			return false;
		}
	}

	// 分页获取 复审核视频模板信息
	public Page pageAuditVideoDesignInfo(Map<String, Object> parm,
			Integer pageNo, Integer pageSize) {
		try {
			Page result = null;
			int skipResults = JspPage.getStartOfPage(pageNo, pageSize);
			int totalSize = videoDesignInfoDao.getAuditVideoDesignInfoCnt(parm);
			while(totalSize >0 && totalSize <= skipResults){
				skipResults= skipResults - pageSize;
				pageNo = pageNo -1;
			}
			parm.put("pageSize", pageSize);
			parm.put("skipResults", skipResults);
			List<VideoDesignDto> data = videoDesignInfoDao.getAuditVideoDesignInfo(parm);
			result = new JspPage(skipResults, totalSize, pageSize, data);
			return result;
		} finally {
		}
	}
	
	/** 分页获取用户视频
	 */
	public Page pageUserViderDoc(Map<String, Object> parm, Integer pageNo,
			Integer pageSize) {
		try {
			Page result = null;
			int skipResults = JspPage.getStartOfPage(pageNo, pageSize);
			int totalSize = videoDesignInfoDao.getUserVideoDocCnt(parm);
			while(totalSize >0 && totalSize <= skipResults){
				skipResults= skipResults - pageSize;
				pageNo = pageNo -1;
			}
			parm.put("pageSize", pageSize);
			parm.put("skipResults", skipResults);
			List<VideoUserDocDto> data = videoDesignInfoDao.getUserVideoDoc(parm);
			result = new JspPage(skipResults, totalSize, pageSize, data);
			return result;
		} finally {
		}
	}
	
	// 添加评审纪录
	public void insertReviewHis(Map<String,Object> param) {
		videoDesignInfoDao.insertReviewHis(param);
	}
	
	// 检索关键词信息
	public List<KeywordInfoDto> selectKeywordInfo(Map<String,Object> param){
			if(param !=null && param.containsKey("design_id")){
				return videoDesignInfoDao.selectDesignKeywordInfo(param);
			}
			
			return videoDesignInfoDao.selectKeywordInfo(param);
	}
	
	
	// 检索视频价格套餐详情
	public List<YjxPriceInfoDto> selectPriceInfo(Map<String,Object> param){
		if(param !=null && param.containsKey("uni_item_id")){
			return videoDesignInfoDao.selectVideoPriceInfo(param);
		}
		
		return videoDesignInfoDao.selectPriceInfo(param);
	}
	
	// 添加视频套餐
	public boolean addPriceRInfo(Map<String, Object> parm) {
		try {
			videoDesignInfoDao.addPriceRInfo(parm);// 添加视频价格套餐信息
			return true;
		} catch (Exception e) {
			return false;
		}
	}
	// 删除价格视频套餐
	public boolean delPriceRInfo(Map<String, Object> parm) {
		try {
			videoDesignInfoDao.delPriceRInfo(parm);// 删除视频价格套餐
			return true;
		} catch (Exception e) {
			return false;
		}
	}
	
	//################################  生成GET和Set方法  ##################################################
	public VideoDesignInfoDao getVideoDesignInfoDao() {
		return videoDesignInfoDao;
	}
	public void setVideoDesignInfoDao(VideoDesignInfoDao videoDesignInfoDao) {
		this.videoDesignInfoDao = videoDesignInfoDao;
	}

	public boolean addVideoFormId(Map<String, Object> parm) {
		try {
			videoDesignInfoDao.addVideoFormId(parm);
			return true;
		} catch (Exception e) {
			return false;
		}
	}

	// 同步删除 模板组内的 视频模板
	public void delTmplSetRInfo(Map<String, Object> parm) {
		videoDesignInfoDao.delTmplSetRInfo(parm);
	}
}
